<?php
declare(strict_types=1);
namespace app\controller;

use think\facade\Db;
use app\model\Wages as WagesModel;

class Wages extends Base
{


    /**
     * 显示指定的资源
     *
     * @param  int  $id
     * @return \think\Response
     */
    public function wagesList()
    {
        $post = request()->param();
        $user_model = new WagesModel();
        $res = $user_model->getAll($post['list_rows'], false, ['query' => $post], $post);
        if ($res[0] !== true) {
            return $this->create($res[1] , '失败', 204);
        }
        return $this->create($res[1] , '成功');
    }
    
    public function staffWagesList()
    {
        $post = request()->param();
        // return $post;
        $user_model = new WagesModel();
        $res = $user_model->getStaffWages($post['work_num']);
        if ($res[0] !== true) {
            return $this->create($res[1] , '失败', 204);
        }
        return $this->create($res[1] , '成功');
    }

    public function updateRoles()
    {
        $post = request()->param();
        $user_model = new WagesModel();
        $user_model->updateRoles($post['work_num'], $post['roles']);
        return $this->create('', '成功');
    }

    public function updateWages()
    {
        $post = request()->param();
        $user_model = new WagesModel();
        $wages = (int)$post['wages'];
        // return $post['name'];
        // return $wages;
        $data = $user_model->updateWages($post['name'], $post['keyname'],$post['wages']);
        // return $post['name']+$post['keyname']+$post['wages'];
        // return $data[1];
        if ($data[0] === 'false') {
            return $this->create($data[1], '失败', 20001);
        }
        return $this->create('', '成功');
    }
    /**
     * 显示资源列表
     *
     * @return \think\Response
     */
    public function index()
    {

        // table方法必须指定完整的数据表名
        return 'hello';
    }
}